package com.javasm.springmybatis.sync;

import com.javasm.springmybatis.utils.SpringContainerUtils;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * @Author：Dilraba
 * @Version：1.0
 * @Date：2021/11/9-15:12
 * @Since:jdk1.8
 * @Description:
 */

//3.AsyncFactory里放的是任务 具体要干的事（发邮件，记录日志，发工资条）
public class AsyncFactory {

    //放的是耗时操作
    public static Runnable sendEmail(String email ,String content){
        return ()->{
            System.out.println(Thread.currentThread().getName());
            JavaMailSender javaMailSender = SpringContainerUtils.getBean(JavaMailSender.class);
            SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
            simpleMailMessage.setFrom("meiko<480694856@qq.com>");
            simpleMailMessage.setSubject("我们是冠军！");
            simpleMailMessage.setText("您的验证码是：  "+content+" 五分钟有效");
            simpleMailMessage.setTo(email);
            javaMailSender.send(simpleMailMessage);
        };
    }

}
